import os
import re
def mylistdir(p,f):
    a=os.listdir(p)
    fs=myfind(a,f)
    return(fs)
def myfind(l,p):
    lr=[];
    #print p
    p1=p.replace(".",r"\.")
    p2=p1.replace("*",".*")
    p2=p2+"$"
    for a in l:
        #print a
        if  re.search(p2,a,re.IGNORECASE)==None :
           pass
           #print "pass"
        else:
           lr.append(a)
       #print "append"
    return lr    
def  getfiles():
    return mylistdir(".","*.ui")
def uiCone(f):        
    f=os.path.splitext(f)
<<<<<<< HEAD
    cmd='/usr/lib/qt6/libexec/uic -g python %s.ui >ui_%s.py' %(f[0],f[0])
=======
    cmd='pyuic5  %s.ui >ui_%s.py' %(f[0],f[0])
>>>>>>> 92bd17086274760d705fd6d4e317cd2a3140a066
    # cmd='/usr/local/bin/PyQt5-uic -g python %s.ui >ui_%s.py' %(f[0],f[0])
    print(cmd)
    os.system(cmd)
def  getfiles_rc():
    return mylistdir(".","*.qrc")
def rCone(f):        
    f=os.path.splitext(f)
    cmd=r'pyrcc5  %s.qrc >%s_rc.py' %(f[0],f[0])
    # cmd=r'%s\Python311\Lib\site-packages\PyQt5\pyuic5  %s.ui >ui_%s.py' %(getpath.getdrive(),f[0],f[0])
    # cmd=r'%s\Python311\scripts\pyuic5  %s.qrc >%s_rc.py' %(getpath.getdrive(),f[0],f[0])
    # cmd=r'%s\Python38\scripts\pyuic5.exe  %s.ui >ui_%s.py' %(getpath.getdrive(),f[0],f[0])
    print(cmd)
    os.system(cmd)
    # runCmd(cmd)
    return cmd
def rc():
    fs=getfiles_rc()
    # out=open("uic.sh","w")
    for f in fs:
        rCone(f)
fs=getfiles()
for f in fs:
    uiCone(f)
fs=getfiles_rc()
for f in fs:
    rCone(f)
